$(function(){
    //------------------------------------------------------------------------------------------------------------------
    //个人会员手机号码验证
    $.validator.addMethod("checkMobile", function(value, element,param) {
        var regu =/(^1[3-9]{1}[0-9]{9}$)/g;
        if(regu.test(value)){
            return true;
        }else{
            return false;
        }
    }, "Please enter the correct cell phone number");

    //请输入正确的身高
    $.validator.addMethod("checkHeight", function(value, element,param) {
        if(value != ''){
            var regu =/(^[0-9]{2,3})$/g;
            if(regu.test(value)){
                return true;
            }else{
                return false;
            }
        }else {
            return true;
        }
    }, "Please enter the correct height");

    //个人QQ号码验证
    $.validator.addMethod("checkQQ", function(value, element,param) {
        if(value != ''){
            var regu =/(^[1-9]{1}[0-9]{4,15})$/g;
            if(regu.test(value)){
                return true;
            }else{
                return false;
            }
        }else {
            return true;
        }
    }, "Please enter the correct QQ number");

    //验证输入时排除中文
    $.validator.addMethod("enName", function(value, element,param) {
        if(value != ''){
            var regu =/[u4e00-u9fa5]/g;
            if(regu.test(value)){
                return true;
            }else{
                return false;
            }
        }else {
            return false;
        }
    }, "Please enter your English name");

    //企业会员表单验证 使用jQuery Validate 插件进行验证
    $('#resumeForm').validate({
        //指定使用什么标签标记错误。
        errorElement: "span",
        //一个函数，可以自定义错误放到哪里。
        errorPlacement: function(error, element) {
            $(element).parents('dl').find(".errinfo").append(error);
        },
        //自定义错误消息
        tipPlacement: function(element,tip) {
            $(element).parents('dl').find(".errinfo").append(tip);
        },
        //通过验证后执行的函数
        success: function(label){
            if(label.parents('dl').find('dd input').val()!=''){
                label.text('ok!').addClass('success');
            }
        },

        //未验证后执行的函数
        highlight: function(element, errorClass) {
            $( element ).closest( "dl" ).find("dd.errinfo").find('span').removeClass('success');
        },
        ignore:"",
        //js上面添加验证规则
        rules: {
            enName: {
                required: true
            },
            sex: {
                required: true
            },
            birthday: {
                required: true
            },
            education: {
                required: true
            },
            mobile: {
                required: true,
                minlength:11,
                checkMobile:true //期望的是true,如果为false则展示提示信息
            },
            email: {
                email: true
            },
            qq: {
                checkQQ:true //期望的是true,如果为false则展示提示信息
            },
            jobStatus: {
                required:true
            },
            homeaddress: {
                required: true
            },
            jobsort1: {
                required: true
            },
            jobarea1: {
                required: true
            },
            intentionjobs: {
                required: true
            },
            height: {
                checkHeight:true //期望的是true,如果为false则展示提示信息
            }
        },
        //错误信息提示修改
        messages: {
            enName: {
                required: "Please enter your English name"
            },
            sex: {
                required: "Please select a gender"
            },
            birthday: {
                required: "Please choose the year of birth"
            },
            education: {
                required: "Please choose the highest degree"
            },
            mobile: {
                required: "Please enter your mobile number",
                minlength: "The number of mobile phone Numbers must be 11 digits"
            },
            email: {
                email: "Please enter a correct mailbox"
            },
            jobStatus: {
                required: "Please choose your employment status"
            },
            homeaddress: {
                required: "Please select your current residence"
            },
            jobsort1: {
                required: "Please choose your job"
            },
            jobarea1: {
                required: "Please select the working area"
            },
            intentionjobs: {
                required: "Please enter your intended position"
            }
        },
        submitHandler:function(form) {
           form.submit();
        }
    });
    //$('form input[placeholder]').placeholder({isUseSpan:true});
});

// ----------------------------------------------------------------------------------------------------------------------------

